﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace devtm.Editor.Configuration.Command
{
    public class CommandRemoveSection : ICommand
    {
        private devtm.Configuration.IElementSection section;

        private int index;

        public CommandRemoveSection(int index, devtm.Configuration.IElementSection section)
        {
            // TODO: Complete member initialization
            this.section = section;
            this.index = index;
        }

        public virtual void Redo()
        {
            Datas.Configuration.Sections.Remove((section.ConfigurationElement as ConfigurationSection).SectionInformation.Name);
            (section.ParentItem as ElementSection).Items.Remove(section);
        }

        public virtual void Undo()
        {
            ConfigurationSection s = section.ConfigurationElement as ConfigurationSection;
            Datas.Configuration.Sections.Add(s.SectionInformation.Name, s);
            (section.ParentItem as ElementSection).Items.Insert(index, section);
        }

    }
}
